Stop escalating dataset delete to dataset destroy - #12639
Conversation
Co-authored-by: Philip Durbin <philip_durbin@harvard.edu>
vera
left a comment
There was a problem hiding this comment.
Looks good to me.
Fixes the original issue #11253 by always restricting the "delete unpublished dataset" API to unpublished datasets (which only have a draft version and nothing else), even if called by a superuser. The restriction to unpublished datasets also keeps the API distinct from the more general "delete dataset draft" API, so there's not two duplicate APIs.
I just left a few minor textual suggestions.
Co-authored-by: Vera Clemens <16904069+vera@users.noreply.github.com>
Conflicts: doc/sphinx-guides/source/api/changelog.rst
As discussed at standup today, Jim already made the doc changes Vera requested. Dismissing.
pdurbin
left a comment
There was a problem hiding this comment.
I found a couple places where tests are failing.
I'm also wordsmithing a bit. 😅
| deleteDatasetResponse.prettyPrint(); | ||
| deleteDatasetResponse.then().assertThat() | ||
| .body("message", containsString("unpublished")) | ||
| .statusCode(FORBIDDEN.getStatusCode()); |
There was a problem hiding this comment.
This is failing:
[ERROR] DatasetsIT.testCreateDataset:354 1 expectation failed.
Expected status code <403> but was <400>.
| deleteDatasetResponse.prettyPrint(); | ||
| deleteDatasetResponse.then().assertThat() | ||
| .body("message", containsString("/destroy")) | ||
| .statusCode(FORBIDDEN.getStatusCode()); |
There was a problem hiding this comment.
Fail:
[ERROR] DatasetsIT.testCreateDataset:361 1 expectation failed.
Expected status code <403> but was <400>.
Co-authored-by: Philip Durbin <philipdurbin@gmail.com>
What this PR does / why we need it: This PR builds on #12332 to close issue #11253, removing the superuser override in the Delete Unpublished Dataset API (which allowed it to work as the Delete Published Dataset API). However, unlike the original, it keeps the restriction that Delete Unpublished Dataset only works on unpublished datasets (those that have only a draft version). The docs are updated to note this restriction and that the Delete Dataset Draft API, which deletes the draft version of any dataset, is the equivalent of Delete Unpublished Dataset when the draft is the only version.
Which issue(s) this PR closes:
Special notes for your reviewer: The error code is changed from UNAUTHORIZED (which probably should have been FORBIDDEN) to 400/BAD_REQUEST when the api is called on a published dataset.
Suggestions on how to test this: Verify that the Delete Unpublished Dataset call works when only a draft exists and that it responds with a 400 error if the dataset is published (has only published versions or if v1 exists and a draft.)
Does this PR introduce a user interface change? If mockups are available, please link/include them here:
Is there a release notes update needed for this change?: included
Additional documentation: